<?php 

session_start();
	
	function getlang(){
		$lang = $_SESSION['lang'];
		if (empty($lang) || $lang == "EN") {
			$value = "../value/value_en.php";
		} else if($lang == "VN") {
			$value = "../value/value_vn.php";
		}
		else if($lang == "KR"){
			$value = "../value/value_kr.php";
		}
		return $value;
	}
	
	$value = getlang();
	include($value);
	$lang = $_SESSION['lang'];
	if($lang=='')
		$lang="EN";
	if($_REQUEST['action']==chPass){
		$passold=$_REQUEST['oldpass'];
		$passnew1=$_REQUEST['newpass1'];
		$passnew2=$_REQUEST['newpass2'];
		
		if(!isset($_SESSION['tkemail'])){
			if(!isset($_COOKIE['tkemail'])){
				$action='entry';
				header( 'Location: index.php' );
			}else {
				$_SESSION['tkemail']=$_COOKIE["tkemail"];
			    $_SESSION['tkemailrestore']=$_COOKIE["tkemailrestore"];
			    $_SESSION['role']=$_COOKIE["role"];
				
				$tkemail=$_SESSION['tkemail'];
			}
		}else 
			$tkemail=$_SESSION['tkemail'];
			
		if(empty($passold))
			$error=$errorProfile1;
		else if(empty($passnew1))
			$error=$errorProfile2;
		else if(empty($passnew2))
			$error=$errorProfile3;
		else{
			include '../connection/connection.php';
			
			
			$passold = md5($passold);
				
			$query = mysql_query("select * from user_info where email='$tkemail' and passwd = '$passold'");
			//echo "select * from user_info where email='$tkemail' and passwd = '$passold'";
			$co=0;
			while ($row=mysql_fetch_array($query)){
				$co=1;
			}
			
			
			if($co==1)
			{
				if($passnew1==$passnew2){
					$passnew1 = md5($passnew1);
					$c = mysql_query("UPDATE user_info SET passwd='$passnew1' WHERE (email='$tkemail')");
					if($c==1)
						$success=$errorProfile4;
				}else{
					$error=$errorProfile5;
				}
			}
			else
				$error=$errorProfile6;
			//mysql_connect($connection);
		}	
	}else{

	}
?>
<style>
* {font-family:Arial, Helvetica, sans-serif; font-size:14px}
#fade { /*--Transparent background layer--*/
        display: none; /*--hidden by default--*/
        background: #727272;
        position: fixed; left: 0; top: 0;
        width: 100%; height: 100%;
        opacity: .50;
        z-index: 9999;
}
.popup_block{
        display: none; /*--hidden by default--*/
        background:url(images/bgn.png);
       
		border-radius: 8px;
        float: left;
        font-size: 1.2em;
        position: fixed;
        top: 50%; left: 50%;
        z-index: 99999;
		width:463px;
		height:264px;
		
        /*--CSS3 Box Shadows--*/
        /*--CSS3 Rounded Corners--*/
}
.btn_close {
	background:url(images/close.png);
        float: right;
        margin: -10px -10px 0 0;
		width:30px;
		height:30px;	
}
/*--Making IE6 Understand Fixed Positioning--*/
*html #fade {
        position: absolute;
}
*html .popup_block {
        position: absolute;
}

.btnupbg {
	/*background: none repeat scroll 0 0 #79AA38;*/
	background:url(images/btn.png) no-repeat;
    border-color: #C4C0B9;
    border-radius: 5px 5px 5px 5px;
    border-width: 0;
    color: white;
    cursor: pointer;
    font-weight: bold;
    height: 28px;
    margin: 6px 0 0 20px;
    padding: 0 5px;
    width: 65px;}
.btnupbg:hover {background:#309DCF}
.btnupload {background: -moz-linear-gradient(center top , #63B6DB, #309DCF) repeat;}
.text{ height:24px;}
</style>
		<a href="#" class="close" onclick="cancelPass()" ><span class="btn_close"></span></a>
   		<table style="margin:26px 7px 7px 7px; no-repeat; width:447px; height:230px">
	    		<tr>
		    	<td style=" width:160px; height:24px; padding:40px 0 0 34px; "><b style="font-size:16px;color: #027acc;"><?=$passwdold?></b></td>
		        <td valign="top"><input  name="passold" id="oldpass" type="password" style="height:28px;width:208px; border:1px solid #ccc; border-radius: 5px; margin:40px 0 0 0;"  value="" /></td>
		        </tr>
		        <tr >
		        <td style=" width:160px; height:24px; padding:0px 0 0 34px; "><b style="color: #027acc;font-size:16px"><?=$passwdnew1?></b></td>
		        <td valign="top"><input name="passnew1" id="newpass1" type="password" style="height:28px;width:208px; border:1px solid #ccc; border-radius: 5px; margin:8px 0 0 0;"  value="" /></td>
		        </tr>
		        <tr>
		        <td style=" width:160px; height:24px; padding:0px 0 0 34px; "><b style="color: #027acc;font-size:16px"><?=$passwdnew2?></b></td>
		        <td valign="top"><input name="passnew2" id="newpass2"  type="password" style="height:28px;width:208px; border:1px solid #ccc; border-radius: 5px; margin:8px 0 0 0;" value="" /></td>
		        </tr>
		        <tr>
		        	<td></td>
		            <td>
		            <input type="button" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;background: url('images/btn.png') !important;" class="btnupbg " value="<?=$agree?>" name="changePass" onclick="changePass()" />
		            <input type="button" class="btnupbg  iclose" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;background: url('images/btn.png') !important;" value="<?=$cancel?>"  name="cancel" onclick="cancelPass()" /></td>
		        </tr>
		        <tr>
		        	<td colspan="2">
		          <?php if(isset($error)){?>
	            		<input type="hidden" id="thongbao" value="error">
	            		<span style="color: red;font-size: 12px" class="lid">(*)<?php echo $error; unset($error);?></span>
	            	
	            	<?php }if(isset($success)){?>
		    			<input type="hidden" id="thongbao" value="success">
		    			<!-- span style="color: green;font-size: 12px" class="lid">(*)<?php echo $success; unset($success);?></span-->
		    		
		    		<?php }?>
		    		</td>
	    		</tr>
    	</table>
